import { ajax } from './util.js';

let deleteBtn = document.querySelectorAll('.deleteBtn');

deleteBtn.forEach(btn => {
    btn.onclick = function () {
        // 获取id
        // console.log(this.dataset.id); 
        if (confirm("确定删除吗？")) {
            ajax.get(
            `/delete/${this.dataset.id}`,
            function (data) {
                if (data.code === 200) {
                    alert('删除成功！');
                    window.location.href ='/list';
                }else{
                    // console.log(data.msg);  
                    alert(data.msg); 
                }
            })
        }
    }
});